Repository navigation
fix: keep X11 layer shell windows on their screen - #1894
Merged
robertkill merged 1 commit intoNov 27, 2026
Merged
Conversation
Reviewer's GuideImplementationClamp an axis back onto the current screen only when the window center leaves it, preventing screen reassignment loops while preserving intentional partial overlap.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="frame/layershell/x11dlayershellemulation.cpp" line_range="214-215" />
<code_context>
QRect rect(x, y, targetWidth, targetHeight);
+ // Prevent screen-change feedback without discarding intentional partial overlap (e.g. notifications).
+ if (rect.left() > screenRect.right() || rect.right() < screenRect.left()) {
+ rect.moveLeft(qMax(screenRect.left(), qMin(x, screenRect.right() + 1 - targetWidth)));
+ }
+ if (rect.top() > screenRect.bottom() || rect.bottom() < screenRect.top()) {
</code_context>
<issue_to_address>
**Off-screen geometry triggers reassignment**
When both opposing anchors are set on an axis and the margins produce a positive-size rectangle wholly outside the screen, `onPositionChanged()` clamps `rect`, but the later opposing-anchor geometry calculation resets its position and size from the margins. Qt can then reassign the window and re-enter positioning without the clamp taking effect.
Apply the clamp to the final geometry after the opposing-anchor calculation.
</issue_to_address>
### Comment 2
<location path="frame/layershell/x11dlayershellemulation.cpp" line_range="215" />
<code_context>
QRect rect(x, y, targetWidth, targetHeight);
+ // Prevent screen-change feedback without discarding intentional partial overlap (e.g. notifications).
+ if (rect.left() > screenRect.right() || rect.right() < screenRect.left()) {
+ rect.moveLeft(qMax(screenRect.left(), qMin(x, screenRect.right() + 1 - targetWidth)));
+ }
+ if (rect.top() > screenRect.bottom() || rect.bottom() < screenRect.top()) {
</code_context>
<issue_to_address>
**Oversized windows leave their screen**
When a layer-shell window is wider than its screen and its position would otherwise be completely outside it, the clamp puts the oversized rectangle's left edge at the screen's left edge but does not keep its center on that screen. Qt can assign the window to a neighboring screen, so subsequent positioning uses that screen's origin and moves the window away from the requested screen.
For dimensions larger than the screen, choose a position that keeps the window associated with the current screen (for example, keep its center there) instead of only clamping its left edge.
</issue_to_address>
|
1. When margins push an X11 layer shell window completely off its screen, Qt reassigns it to the neighbouring screen and positioning re-enters with the new origin, ping-ponging between screens forever and freezing dde-shell (e.g. moving the dock to the left on dual screens with 125% scaling). 2. After the final geometry is computed (including opposite anchors), move an axis back only when the window center leaves the current screen on that axis, matching how Qt picks the window's screen; a window larger than the screen is centered on it. Intentional partial overlap such as the full-height notification bubble avoiding the dock is preserved. Influence: 1. On dual screens with scaling, switch the dock between bottom, left, top and right from the context menu; dde-shell must not freeze 2. Open and close the windowed launcher on primary and secondary screens 3. With the dock at the bottom or right, send a notification and verify it does not overlap the dock fix: X11 下 layer shell 窗口保持在所在屏幕 1. 边距把 X11 layer shell 窗口完全推出所在屏幕时,Qt 会把窗口改归相邻屏幕, 定位逻辑以新屏幕原点再次进入,在两块屏幕间反复切换,导致 dde-shell 卡死 (如双屏 125% 缩放下将任务栏切到左侧) 2. 在最终几何(含两侧锚定)计算完成后,仅当窗口中心在某一轴上离开当前屏幕时 才把该轴拉回,与 Qt 按中心点判定所属屏幕一致;比屏幕大的窗口居中于当前屏幕。 保留通知气泡等有意的部分越界以避让任务栏 Influence: 1. 双屏缩放环境下通过右键菜单在底部、左侧、顶部、右侧间切换任务栏位置,dde-shell 不卡死 2. 在主副屏打开、关闭窗口模式启动器 3. 任务栏位于底部或右侧时发送通知,确认通知不与任务栏重叠 Log: 修复双屏缩放下切换任务栏位置导致界面卡死的问题 PMS: BUG-384699
robertkill
force-pushed
the
fix/bug-384699-layershell-screen
branch
from
November 27, 2026 07:15
7cab148 to
a4bc0f0
Compare
18202781743
approved these changes
Nov 27, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, robertkill The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This was referenced Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On X11, when layer-shell margins push a window completely off its screen (e.g. moving the dock to the left on dual screens with 125% scaling), Qt reassigns the window to the neighbouring screen;
onPositionChanged()re-enters with the new screen origin and the window ping-pongs between screens forever, freezing dde-shell.After the final geometry is computed (including opposite anchors), this change moves an axis back only when the window center leaves the current screen on that axis — the same rule Qt uses (
QWindowPrivate::screenForGeometry) to pick the window's screen. A window larger than the screen is centered on it. Intentional partial overlap (the full-height notification bubble shifted up to avoid a bottom dock) is preserved.Verification
onPositionChanged()body against QtQRect: launchpad with oversized margin on primary/secondary screen, notification avoiding bottom/right dock, dock with opposite anchors, center crossing into the neighbour while still overlapping, opposite anchors with negative margins, window wider than its screen — 9/9 pass. A randomized check (300k cases, two-screen layouts, Qt 6.8 screen-selection rule) verifies the center always stays on the current screen, placement is idempotent and settles in ≤2 passes on the original screen, sizes are unchanged, and axes upstream already kept on screen are untouched; upstream loops or switches screens in 14,142 of them.20dd983e): 300 passed, 1 pre-existing disabled.Not covered: Wayland, notification click actions, third-party plugins. The real-machine run used the 2.0.61 base;
onPositionChanged()is byte-identical on both bases.PMS: BUG-384699